﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NetworkLib.Utilities;

namespace PokemonBattle.BattleRoom.Server
{
    public enum UserState
    {
        Free = 419938667,
        Challenging = 222308226,
        Battling = -1069528294,
        Away = -848236796,
        WrongInput = -1
    }

    public static class UserStateHelper
    {
        public static UserState ReadFromByteArray(ByteArray byteArray)
        {
            int val = byteArray.ReadInt();
            return Parse(val);
        }

        public static UserState Parse(int val)
        {
            foreach (int value in Enum.GetValues(typeof(UserState)))
            {
                if (value == val) return (UserState)value;
            }

            return UserState.WrongInput;
        }

        public static void WriteToByteArray(ByteArray byteArray, UserState value)
        {
            byteArray.WriteInt((int)value);
        }
    }
}
